
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import axios from 'axios';
import { useUserStore } from '../store/index.ts'
import ShowInvestPage from '../views/Invests/ShowInvestPage.vue'
import AdminInvestInfo from '../views/Invests/AdminInvestInfo.vue'
import UserShowInvestPage from '../views/Invests/UserShowInvestPage.vue'
import ShowInvestManage from '../views/Invests/ShowInvestManage.vue'
import AdminRedeemInvest from '../views/Invests/AdminRedeemInvest.vue'
import UserInfo from '../views/Users/UserInfo.vue'
import AdminCheckUserInfo from '../views/Users/AdminCheckUserInfo.vue'
import ShowUserAsset from '../views/Users/ShowUserAsset.vue'
import ShowAssetInfo from '../views/Users/ShowAssetInfo.vue'

//实例仓库
const UserState = useUserStore();

//创建响应对象，用于保存用户类型
const Utype = ref('');

//生命周期钩子
onMounted(() => {
    axios({
        method: "get",
        url: "https://localhost:44305/api/Users/GetUserTypeInfo",
        params: {
            Uid: UserState.UserLoginId
        }
    })
        .then(function (res) {
            Utype.value = res.data[0].UT_Name;
        })
        .catch(function (error) {
            console.log(error);
        })
})


const Imange = ref(false);
const Iamanage = ref(false);
const Amanage = ref(false);
const Umanage = ref(false);
const Zmanage = ref(false);
const TakeInfo = (msg: string) => {
    switch (msg) {
        case 'Pt':
            Imange.value = true;
            //投资管理状态为false
            Iamanage.value = false;
            break;
        case 'IM':
            Iamanage.value = true;
            //项目管理赋值为false
            Imange.value = false;
            break;
        case 'Asset':
            //项目管理、投资管理状态为false
            Imange.value = false;
            Iamanage.value = false;
            Amanage.value = true;
            break;
        case 'UM':
            //项目管理，投资管理状态设置为false
            Imange.value = false;
            Iamanage.value = false;
            Amanage.value = false;

            Umanage.value = true;
            break;
        case 'AT':
            Imange.value = false;
            Iamanage.value = false;
            Amanage.value = false;
            Umanage.value = false;

            Zmanage.value = true;
            break;
    }
}

</script>


<template>
    <!--BEGIN HEADER-->
    <div class="pure-menu pure-menu-open pure-menu-horizontal pure-menu-fixed head-menu">
        <a href="#" class="pure-menu-heading">
            <h3>物联网金融管理系统</h3>
        </a>
        <ul>
            <li class="pure-menu-selected"><a href="#" @click="TakeInfo('UM')">用户管理</a></li>
            <li><a href="#" @click="TakeInfo('AT')">账户管理</a></li>
            <li>
                <a href="#" v-show="Utype == 'admin'" @click="TakeInfo('Pt')">项目管理</a>
            </li>
            <li><a href="#" @click="TakeInfo('IM')">投资管理</a></li>
            <li><a href="#" @click="TakeInfo('Asset')">资产管理</a></li>
        </ul>
        <div class="head-menu-info">
            欢迎您， <a>{{ Utype }}</a>。您选择【首页】【退出】
        </div>
    </div>
    <div>
        <div class="pure-u-1">
            <div class="main">
                <div class="panel panel-default">
                    <div v-show="Imange">
                        <ShowInvestPage></ShowInvestPage>
                    </div>
                    <div v-show="Iamanage && Utype == 'admin'">
                        <AdminInvestInfo></AdminInvestInfo>
                    </div>
                    <div v-show="Iamanage && Utype == '用户'">
                        <UserShowInvestPage></UserShowInvestPage>
                    </div>
                    <div v-show="Amanage && Utype == '用户'">
                        <ShowInvestManage></ShowInvestManage>
                    </div>
                    <div v-show="Amanage && Utype == 'admin'">
                        <AdminRedeemInvest></AdminRedeemInvest>
                    </div>
                    <div v-show="Umanage && Utype == '用户'">
                        <UserInfo></UserInfo>
                    </div>
                    <div v-show="Umanage && Utype == 'admin'">
                        <AdminCheckUserInfo></AdminCheckUserInfo>
                    </div>
                    <div v-show="Zmanage && Utype == 'admin'">
                        <ShowUserAsset></ShowUserAsset>
                    </div>
                    <div v-show="Zmanage && Utype == '用户'">
                        <ShowAssetInfo></ShowAssetInfo>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--BEGIN FOOT-->
    <div class="pure-g copyright">
        <div class="pure-u-1"> 2109 sys </div>
    </div>
    <!--END FOOT-->
    <RouterView></RouterView>
</template>


<style scoped>
@import '../../src/assets/DomCss/css/pure-nr-min.css';
@import '../../src/assets/DomCss/css/fontAwesome/font-awesome.css';
@import '../../src/assets/DomCss/css/main.css';
@import '../../src/assets/DomCss/css/admin.css';
</style>